import 'package:flutter/material.dart';

class IWrap extends StatelessWidget {
  const IWrap({
    super.key,
    this.column = 4,
    this.spacing = 0,
    this.runSpacing = 0,
    this.itemCount = 8,
    required this.itemBuilder,
  });
  final int itemCount;
  final IndexedWidgetBuilder itemBuilder;
  final int column;
  final double spacing;
  final double runSpacing;
  @override
  Widget build(BuildContext context) {
    if (itemCount == 0) {
      return const SizedBox();
    }
    return LayoutBuilder(builder: (context, cons) {
      var itemW = ((cons.biggest.width - (column - 1) * spacing) / column)
          .floorToDouble();
      return Wrap(
        spacing: spacing,
        runSpacing: runSpacing,
        children: List.generate(itemCount, (index) {
          return SizedBox(
            width: itemW,
            child: itemBuilder(context, index),
          );
        }),
      );
    });
  }
}
